
function dbGet(key: string, sync = true) {
  if (sync) {
    return uni.getStorageSync(key);
  } else {
    let data = "";
    uni.getStorage({
      key: key,
      success: function (res) {
        data = res.data;
      },
    });
    return data;
  }
}

//赋值
function dbSet(key: string, value: string, sync = true) {
  if (sync) {
    return uni.setStorageSync(key, value);
  } else {
    uni.setStorage({
      key: key,
      data: value,
    });
  }
}
//移除
function dbDel(key: string, sync = true) {
  if (sync) {
    return uni.removeStorageSync(key);
  } else {
    uni.removeStorage({
      key: key,
    });
  }
}

//清空
function dbClear(sync = true) {
  if (sync) {
    return uni.clearStorageSync();
  } else {
    uni.clearStorage();
  }
}

export { dbGet, dbSet, dbDel, dbClear };
